package com.another.common.utils.common;


import com.alibaba.fastjson.JSON;
import com.another.common.utils.result.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by Another on 2017/7/26.
 */
public class MyException extends RuntimeException {

    private Logger logger= LoggerFactory.getLogger(this.getClass());

    private Integer code;
    private String message;

    public MyException(ResultEnum resultEnum) {
        super(resultEnum.getMsg());
        logger.info("出异常了:"+JSON.toJSONString(resultEnum));
        setCode(resultEnum.getCode());
    }

    public MyException(String message) {
        super(message);
        logger.info("出异常了:"+message);
        setCode(ResultEnum.ERROR.getCode());
        setMessage(message);

    }

    public MyException(Integer code, String message) {
        super(message);
        logger.info("出异常了:"+code+":"+message);
        setCode(code);
        setMessage(message);

    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }


    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

}
